#ifndef SNT_TEXT_DOUBLE_H
#define SNT_TEXT_DOUBLE_H

#include "sntText.h"
#include "snt.h"

namespace sntText{

using namespace snt::text;

struct TDouble : public TToken
{
  struct TFuncClosureDoEntryParams
  {
    TDouble     &Double;
    svl::TString OutError;
    //
    TFuncClosureDoEntryParams(TDouble &Double_) : Double(Double_) {}
  };
  typedef fastdelegate::FastDelegate<bool(TFuncClosureDoEntryParams &Params)> TFuncClosureDoEntry;

  template<class PObj,class PFunc> TToken &NewClosure(PObj pObj,PFunc pFunc) {
    TDouble *P = new TDouble(context); 
      P->funcClosureDoEntry.bind(pObj,pFunc);
      P->isNew = true; 
    return *P;
  }

  TDouble(TContext &Context);
  //
  TToken &New(svl::TVariant &Value);
  //
  svl::TVariant &GetValue() { if (!value) { Except("GetValue[!value]"); } return *value; }

protected:
  virtual svl::TString GetInfo(EOutGraphInfo OutGraphInfo);
  bool MakeValue(double &Value,int &Len);
  //
  virtual bool EnEntry();
  virtual bool DoEntry();
  virtual void DoError();
  
private: svl_Except;
  TContext  &context;
  svl::TVariant *value,defValue;
  int nLine,nCol;
  svl::TString error;
  
  TFuncClosureDoEntry funcClosureDoEntry;
};

}

#endif